/*
 * @Author: zwf 240970521@qq.com
 * @Date: 2023-08-02 22:49:59
 * @LastEditors: zwf 240970521@qq.com
 * @LastEditTime: 2023-08-22 21:27:56
 * @FilePath: /esp32_motor/motor/inc/fluxObserver.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef FLUX_OBSERVER_H
#define FLUX_OBSERVER_H

#include "math_common.h"

typedef struct
{
    _iq27 rs;
    _iq27 ls;
    _iq27 flux;
    _iq27 flux2;
    int   gainOdrive;
    _iq27 x1;
    _iq27 x2;
    _iq27 x1Dot;
    _iq27 x2Dot;
    _iq27 x1L;
    _iq27 x1R;
    _iq27 x2L;
    _iq27 x2R;
    _iq27 iAlphaPrev;
    _iq27 iBetaPrev;
    _iq27 vAlphaPrev;
    _iq27 vBetaPrev;
    _iq27 lambdaEst;
    _iq27 lambdaEstOnce;
    _iq27 lambdaMax;
    _iq27 lambdaMin;
    _iq2  gain;
    _iq24 pllKi;
    _iq24 pllKp;
    _iq27 pllErr;
    _iq27 pllInterg;
    _iq27 pllUi;
    _iq27 ctrlTs;
    _iq21 speedGain;
    _iq24 err;
    _iq24 angle;
    _iq21 speedHz;
} FluxObserverObj;

typedef struct
{
    _iq24 iBeta;
    _iq24 iAlpha;
    _iq24 vAlpha;
    _iq24 vBeta;
} FluxObserverPara;

extern FluxObserverObj fluxOb;

/*函数*/
esp_err_t FLUX_observerInit(void);
void      FLUX_observer(FluxObserverPara para);
void      FLUX_observerOriginal(FluxObserverPara para);
void      FLUX_observerMxlemmingLambdaComp(FluxObserverPara para);
void      FLUX_observerMxlemming(FluxObserverPara para);
void      FLUX_observerOrtegaLambdaComp(FluxObserverPara para);
void      FLUX_observerOdrive(FluxObserverPara para);

#endif
